package com.qcxy.gzy.activity;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import com.qcxy.gyz.consts.CMDConts;
import com.qcxy.gzy.activity.base.BaseActivity;
import com.qcxy.gzy.activity.base.BaseAdaptiveActivity;
import com.qcxy.gzy.bean.ComReceiveDataBean;
import com.qxcy.gzy.util.DataCovertUtil;
import com.qxcy.gzy.util.SPUtils;

public class SettingActivity extends BaseActivity implements OnClickListener {

    private LinearLayout mLlCsmm;
    private LinearLayout mLlDlfs;
    private LinearLayout mLlSbxh;
    private LinearLayout mLlXzyy;
    private LinearLayout mLlWifi;
    private LinearLayout mLlTymm;
    private LinearLayout mLlXfcs;

    private TextView mTvCsmm;
    private TextView mTvDlfs;
    private TextView mTvSbxh;
    private TextView mTvXzyy;
    private TextView mTvWifi;
    private TextView mTvTymm;
    private TextView mTvXfcs;

    private Drawable mCsmmSelect;
    private Drawable mCsmmNot;
    private Drawable mDlfsSelect;
    private Drawable mDlfsNot;
    private Drawable mSbxhSelect;
    private Drawable mSbxhNot;
    private Drawable mXzyySelect;
    private Drawable mXzyyNot;
    private Drawable mWifiSelect;
    private Drawable mWifiNot;
    private Drawable mTymmSelect;
    private Drawable mTymmNot;

    private LinearLayout mCsmmPage;
    private LinearLayout mDlfsPage;
    private LinearLayout mSbxhPage;
    private LinearLayout mXzyyPage;
    private LinearLayout mTymmPage;
    private LinearLayout mWifiPage;
    private LinearLayout mSfcsPage;

    private EditText mStartPwd;
    private EditText mNewPwd;

    private EditText mA;
    private EditText mB;
    private EditText mC;
    private EditText mD;

    private TextView mTymmYes;
    private TextView mTymmNo;

    private TextView mXzyyChina;
    private TextView mXzyyEnglish;

    private TextView mTestConn;
    private TextView mTvKzqll;
    private TextView mTvQbll;
    private TextView mTvXsz;
    private TextView mTvXsxs;

    private EditText mSetQbll;
    private EditText mSetXsz;
    private EditText mSetXsxs;
    private TextView mGetStruts;

    private EditText mSetHsll01;
    private EditText mSetHsll02;
    private EditText mSetHsll03;
    private EditText mSetHsll04;
    private EditText mSetHsll05;
    private EditText mSetHsll06;
    private EditText mSetHsll07;
    private EditText mSetHsll08;
    private EditText mSetHsll09;
    private EditText mSetHsll10;
    private EditText mSetHsll11;

    private byte[] Temporary = null;

    private Spinner sn_xfkzqll;

    private ArrayList<byte[]> list = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        findViewById(R.id.iv_back).setOnClickListener(this);
        ((TextView) findViewById(R.id.item_common_title)).setText(R.string.setting_text);

        mLlCsmm = (LinearLayout) findViewById(R.id.ll_csmm);
        mLlDlfs = (LinearLayout) findViewById(R.id.ll_dlfs);
        mLlSbxh = (LinearLayout) findViewById(R.id.ll_sbxh);
        mLlXzyy = (LinearLayout) findViewById(R.id.ll_xzyy);
        mLlWifi = (LinearLayout) findViewById(R.id.ll_wifi);
        mLlTymm = (LinearLayout) findViewById(R.id.ll_tymm);
        mLlXfcs = (LinearLayout) findViewById(R.id.ll_xfcs);

        mTvCsmm = (TextView) findViewById(R.id.tv_csmm);
        mTvDlfs = (TextView) findViewById(R.id.tv_dlfs);
        mTvSbxh = (TextView) findViewById(R.id.tv_sbxh);
        mTvXzyy = (TextView) findViewById(R.id.tv_xzyy);
        mTvWifi = (TextView) findViewById(R.id.tv_wifi);
        mTvTymm = (TextView) findViewById(R.id.tv_tymm);
        mTvXfcs = (TextView) findViewById(R.id.tv_xfcs);

        mTestConn = (TextView) findViewById(R.id.tv_testConn);
        mTvKzqll = (TextView) findViewById(R.id.tv_kzqll);
        mTvQbll = (TextView) findViewById(R.id.tv_qbll);

        mCsmmSelect = this.getResources().getDrawable(
                R.drawable.icon_setting_csmm_select);
        mCsmmNot = this.getResources().getDrawable(
                R.drawable.icon_setting_csmm_not);
        mDlfsSelect = this.getResources().getDrawable(
                R.drawable.icon_setting_dlfs_select);
        mDlfsNot = this.getResources().getDrawable(
                R.drawable.icon_setting_dlfs_not);
        mSbxhSelect = this.getResources().getDrawable(
                R.drawable.icon_setting_sbxh_select);
        mSbxhNot = this.getResources().getDrawable(
                R.drawable.icon_setting_sbxh_not);
        mXzyySelect = this.getResources().getDrawable(
                R.drawable.icon_setting_xzyy_select);
        mXzyyNot = this.getResources().getDrawable(
                R.drawable.icon_setting_xzyy_not);
        mWifiSelect = this.getResources().getDrawable(
                R.drawable.icon_setting_wifi_select);
        mWifiNot = this.getResources().getDrawable(
                R.drawable.icon_setting_wifi_not);
        mTymmSelect = this.getResources().getDrawable(
                R.drawable.icon_setting_tyms_select);
        mTymmNot = this.getResources().getDrawable(
                R.drawable.icon_setting_tyms_not);

        mCsmmSelect.setBounds(0, 0, mCsmmSelect.getMinimumWidth(),
                mCsmmSelect.getMinimumHeight());
        mCsmmNot.setBounds(0, 0, mCsmmNot.getMinimumWidth(),
                mCsmmNot.getMinimumHeight());
        mDlfsSelect.setBounds(0, 0, mDlfsSelect.getMinimumWidth(),
                mDlfsSelect.getMinimumHeight());
        mDlfsNot.setBounds(0, 0, mDlfsNot.getMinimumWidth(),
                mDlfsNot.getMinimumHeight());
        mSbxhSelect.setBounds(0, 0, mSbxhSelect.getMinimumWidth(),
                mSbxhSelect.getMinimumHeight());
        mSbxhNot.setBounds(0, 0, mSbxhNot.getMinimumWidth(),
                mSbxhNot.getMinimumHeight());
        mXzyySelect.setBounds(0, 0, mXzyySelect.getMinimumWidth(),
                mXzyySelect.getMinimumHeight());
        mXzyyNot.setBounds(0, 0, mXzyyNot.getMinimumWidth(),
                mXzyyNot.getMinimumHeight());
        mWifiSelect.setBounds(0, 0, mWifiSelect.getMinimumWidth(),
                mWifiSelect.getMinimumHeight());
        mWifiNot.setBounds(0, 0, mWifiNot.getMinimumWidth(),
                mWifiNot.getMinimumHeight());
        mTymmSelect.setBounds(0, 0, mTymmSelect.getMinimumWidth(),
                mTymmSelect.getMinimumHeight());
        mTymmNot.setBounds(0, 0, mTymmNot.getMinimumWidth(),
                mTymmNot.getMinimumHeight());

        mCsmmPage = (LinearLayout) findViewById(R.id.ll_csmm_page);
        mDlfsPage = (LinearLayout) findViewById(R.id.ll_dlfs_page);
        mSbxhPage = (LinearLayout) findViewById(R.id.ll_sbxh_page);
        mXzyyPage = (LinearLayout) findViewById(R.id.ll_xzyy_page);
        mTymmPage = (LinearLayout) findViewById(R.id.ll_tymm_page);
        mWifiPage = (LinearLayout) findViewById(R.id.ll_wifi_page);
        mSfcsPage = (LinearLayout) findViewById(R.id.ll_xfcs_page);

        mLlCsmm.setOnClickListener(this);
        mLlDlfs.setOnClickListener(this);
        mLlSbxh.setOnClickListener(this);
        mLlXzyy.setOnClickListener(this);
        mLlWifi.setOnClickListener(this);
        mLlTymm.setOnClickListener(this);
        mLlXfcs.setOnClickListener(this);

        mStartPwd = (EditText) findViewById(R.id.start_pwd);
        mNewPwd = (EditText) findViewById(R.id.new_pwd);

        mA = (EditText) findViewById(R.id.A);
        mB = (EditText) findViewById(R.id.B);
        mC = (EditText) findViewById(R.id.C);
        mD = (EditText) findViewById(R.id.D);

        findViewById(R.id.btn_ok).setOnClickListener(this);

        findViewById(R.id.tv_card).setOnClickListener(this);
        findViewById(R.id.tv_scan).setOnClickListener(this);

        findViewById(R.id.choose_china).setOnClickListener(this);
        findViewById(R.id.choose_english).setOnClickListener(this);

        findViewById(R.id.wifi).setOnClickListener(this);
        findViewById(R.id.socket).setOnClickListener(this);
        findViewById(R.id.btn_ok_socket).setOnClickListener(this);

        mTymmYes = (TextView) findViewById(R.id.tv_tymm_yes);
        mTymmNo = (TextView) findViewById(R.id.tv_tymm_no);
        mTymmYes.setOnClickListener(this);
        mTymmNo.setOnClickListener(this);

        mXzyyChina = (TextView) findViewById(R.id.choose_china);
        mXzyyEnglish = (TextView) findViewById(R.id.choose_english);
        mSetQbll = (EditText) findViewById(R.id.et_xfqbll);
        mTvXsz = (TextView) findViewById(R.id.tv_xsz);
        mSetXsz = (EditText) findViewById(R.id.et_xfxsz);
        mTvXsxs = (TextView) findViewById(R.id.tv_xszxs);
        mSetXsxs = (EditText) findViewById(R.id.et_xfxsxs);
        mGetStruts = (TextView) findViewById(R.id.tv_getstruts);
        mSetHsll01 = (EditText) findViewById(R.id.et_hsll1);
        mSetHsll02 = (EditText) findViewById(R.id.et_hsll2);
        mSetHsll03 = (EditText) findViewById(R.id.et_hsll3);
        mSetHsll04 = (EditText) findViewById(R.id.et_hsll4);
        mSetHsll05 = (EditText) findViewById(R.id.et_hsll5);
        mSetHsll06 = (EditText) findViewById(R.id.et_hsll6);
        mSetHsll07 = (EditText) findViewById(R.id.et_hsll7);
        mSetHsll08 = (EditText) findViewById(R.id.et_hsll8);
        mSetHsll09 = (EditText) findViewById(R.id.et_hsll9);
        mSetHsll10 = (EditText) findViewById(R.id.et_hsll10);
        mSetHsll11 = (EditText) findViewById(R.id.et_hsll11);

        findViewById(R.id.btn_testConn).setOnClickListener(this);
        findViewById(R.id.btn_getLzqLl).setOnClickListener(this);
        findViewById(R.id.btn_xfkzqll).setOnClickListener(this);
        findViewById(R.id.btn_getQbLi).setOnClickListener(this);
        findViewById(R.id.btn_xfqbll).setOnClickListener(this);
        findViewById(R.id.btn_getXsz).setOnClickListener(this);
        findViewById(R.id.btn_xfxsz).setOnClickListener(this);
        findViewById(R.id.btn_getXszXS).setOnClickListener(this);
        findViewById(R.id.btn_xfxsxs).setOnClickListener(this);
        findViewById(R.id.btn_getstruts).setOnClickListener(this);
        findViewById(R.id.btn_setyes).setOnClickListener(this);
        findViewById(R.id.btn_setno).setOnClickListener(this);
        findViewById(R.id.btn_gethsll).setOnClickListener(this);
        findViewById(R.id.btn_sethsll).setOnClickListener(this);

        sn_xfkzqll = (Spinner) findViewById(R.id.sn_xfkzqll);
    }

    @Override
    public void onClick(View v) {
        // TODO Auto-generated method stub
        ImageView mSetCardLogin = (ImageView) findViewById(R.id.set_card_login);
        ImageView mSetScanLogin = (ImageView) findViewById(R.id.set_scan_login);
        Drawable drawable = getResources().getDrawable(R.drawable.ic_set_ok);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(),
                drawable.getMinimumHeight());
        switch (v.getId()) {
            case R.id.iv_back:
                Intent intent = new Intent(SettingActivity.this, MainActivity.class);
                startActivity(intent);
                SettingActivity.this.finish();
                break;

            case R.id.ll_csmm:
                mLlCsmm.setBackgroundColor(this.getResources().getColor(
                        R.color.suo_color));
                mLlDlfs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlSbxh.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXzyy.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlWifi.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlTymm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXfcs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));

                mTvCsmm.setCompoundDrawables(mCsmmSelect, null, null, null);
                mTvDlfs.setCompoundDrawables(mDlfsNot, null, null, null);
                mTvSbxh.setCompoundDrawables(mSbxhNot, null, null, null);
                mTvXzyy.setCompoundDrawables(mXzyyNot, null, null, null);
                mTvWifi.setCompoundDrawables(mWifiNot, null, null, null);
                mTvTymm.setCompoundDrawables(mTymmNot, null, null, null);
                mTvXfcs.setCompoundDrawables(mSbxhNot, null, null, null);

                mTvCsmm.setTextColor(this.getResources().getColor(
                        R.color.white_color));
                mTvDlfs.setTextColor(this.getResources().getColor(
                        R.color.card_color));
                mTvSbxh.setTextColor(this.getResources().getColor(
                        R.color.setting_color));
                mTvXzyy.setTextColor(this.getResources().getColor(
                        R.color.scan_color));
                mTvWifi.setTextColor(this.getResources().getColor(
                        R.color.wifi_color));
                mTvTymm.setTextColor(this.getResources().getColor(
                        R.color.visitor_color));
                mTvXfcs.setTextColor(this.getResources().getColor(
                        R.color.setting_color));

                mCsmmPage.setVisibility(View.VISIBLE);
                mDlfsPage.setVisibility(View.GONE);
                mSbxhPage.setVisibility(View.GONE);
                mXzyyPage.setVisibility(View.GONE);
                mTymmPage.setVisibility(View.GONE);
                mWifiPage.setVisibility(View.GONE);
                mSfcsPage.setVisibility(View.GONE);
                break;

            case R.id.ll_dlfs:
                mLlCsmm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlDlfs.setBackgroundColor(this.getResources().getColor(
                        R.color.card_color));
                mLlSbxh.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXzyy.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlWifi.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlTymm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXfcs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));

                mTvCsmm.setCompoundDrawables(mCsmmNot, null, null, null);
                mTvDlfs.setCompoundDrawables(mDlfsSelect, null, null, null);
                mTvSbxh.setCompoundDrawables(mSbxhNot, null, null, null);
                mTvXzyy.setCompoundDrawables(mXzyyNot, null, null, null);
                mTvWifi.setCompoundDrawables(mWifiNot, null, null, null);
                mTvTymm.setCompoundDrawables(mTymmNot, null, null, null);
                mTvXfcs.setCompoundDrawables(mTymmNot, null, null, null);
                mTvXfcs.setCompoundDrawables(mSbxhNot, null, null, null);

                mTvCsmm.setTextColor(this.getResources()
                        .getColor(R.color.suo_color));
                mTvDlfs.setTextColor(this.getResources().getColor(
                        R.color.white_color));
                mTvSbxh.setTextColor(this.getResources().getColor(
                        R.color.setting_color));
                mTvXzyy.setTextColor(this.getResources().getColor(
                        R.color.scan_color));
                mTvWifi.setTextColor(this.getResources().getColor(
                        R.color.wifi_color));
                mTvTymm.setTextColor(this.getResources().getColor(
                        R.color.visitor_color));
                mTvXfcs.setTextColor(this.getResources().getColor(
                        R.color.setting_color));

                mCsmmPage.setVisibility(View.GONE);
                mDlfsPage.setVisibility(View.VISIBLE);
                mSbxhPage.setVisibility(View.GONE);
                mXzyyPage.setVisibility(View.GONE);
                mTymmPage.setVisibility(View.GONE);
                mWifiPage.setVisibility(View.GONE);
                mSfcsPage.setVisibility(View.GONE);

                if (SPUtils.getValueFromSharedFile(this, "card", "INVISIBLE")
                        .equals("VISIBLE")) {
                    mSetCardLogin.setVisibility(View.VISIBLE);
                } else {
                    mSetCardLogin.setVisibility(View.INVISIBLE);
                }
                if (SPUtils.getValueFromSharedFile(this, "scan", "INVISIBLE")
                        .equals("VISIBLE")) {
                    mSetScanLogin.setVisibility(View.VISIBLE);
                } else {
                    mSetScanLogin.setVisibility(View.INVISIBLE);
                }
                break;

            case R.id.ll_sbxh:
                mLlCsmm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlDlfs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlSbxh.setBackgroundColor(this.getResources().getColor(
                        R.color.setting_color));
                mLlXzyy.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlWifi.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlTymm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXfcs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));

                mTvCsmm.setCompoundDrawables(mCsmmNot, null, null, null);
                mTvDlfs.setCompoundDrawables(mDlfsNot, null, null, null);
                mTvSbxh.setCompoundDrawables(mSbxhSelect, null, null, null);
                mTvXzyy.setCompoundDrawables(mXzyyNot, null, null, null);
                mTvWifi.setCompoundDrawables(mWifiNot, null, null, null);
                mTvTymm.setCompoundDrawables(mTymmNot, null, null, null);
                mTvXfcs.setCompoundDrawables(mSbxhNot, null, null, null);

                mTvCsmm.setTextColor(this.getResources()
                        .getColor(R.color.suo_color));
                mTvDlfs.setTextColor(this.getResources().getColor(
                        R.color.card_color));
                mTvSbxh.setTextColor(this.getResources().getColor(
                        R.color.white_color));
                mTvXzyy.setTextColor(this.getResources().getColor(
                        R.color.scan_color));
                mTvWifi.setTextColor(this.getResources().getColor(
                        R.color.wifi_color));
                mTvTymm.setTextColor(this.getResources().getColor(
                        R.color.visitor_color));
                mTvXfcs.setTextColor(this.getResources().getColor(
                        R.color.setting_color));

                mCsmmPage.setVisibility(View.GONE);
                mDlfsPage.setVisibility(View.GONE);
                mSbxhPage.setVisibility(View.VISIBLE);
                mXzyyPage.setVisibility(View.GONE);
                mTymmPage.setVisibility(View.GONE);
                mWifiPage.setVisibility(View.GONE);
                mSfcsPage.setVisibility(View.GONE);
                break;

            case R.id.ll_xzyy:
                mLlCsmm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlDlfs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlSbxh.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXzyy.setBackgroundColor(this.getResources().getColor(
                        R.color.scan_color));
                mLlWifi.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlTymm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXfcs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));

                mTvCsmm.setCompoundDrawables(mCsmmNot, null, null, null);
                mTvDlfs.setCompoundDrawables(mDlfsNot, null, null, null);
                mTvSbxh.setCompoundDrawables(mSbxhNot, null, null, null);
                mTvXzyy.setCompoundDrawables(mXzyySelect, null, null, null);
                mTvWifi.setCompoundDrawables(mWifiNot, null, null, null);
                mTvTymm.setCompoundDrawables(mTymmNot, null, null, null);
                mTvXfcs.setCompoundDrawables(mSbxhNot, null, null, null);

                mTvCsmm.setTextColor(this.getResources()
                        .getColor(R.color.suo_color));
                mTvDlfs.setTextColor(this.getResources().getColor(
                        R.color.card_color));
                mTvSbxh.setTextColor(this.getResources().getColor(
                        R.color.setting_color));
                mTvXzyy.setTextColor(this.getResources().getColor(
                        R.color.white_color));
                mTvWifi.setTextColor(this.getResources().getColor(
                        R.color.wifi_color));
                mTvTymm.setTextColor(this.getResources().getColor(
                        R.color.visitor_color));
                mTvXfcs.setTextColor(this.getResources().getColor(
                        R.color.setting_color));

                mCsmmPage.setVisibility(View.GONE);
                mDlfsPage.setVisibility(View.GONE);
                mSbxhPage.setVisibility(View.GONE);
                mXzyyPage.setVisibility(View.VISIBLE);
                mTymmPage.setVisibility(View.GONE);
                mWifiPage.setVisibility(View.GONE);
                mSfcsPage.setVisibility(View.GONE);

                if (SPUtils.getValueFromSharedFile(this, "LANGUAGE_KEY", "zh-CN")
                        .equals("zh-CN")) {
                    mXzyyChina.setCompoundDrawables(null, null, drawable, null);
                } else {
                    mXzyyEnglish.setCompoundDrawables(null, null, drawable, null);
                }
                break;

            case R.id.ll_wifi:
                mLlCsmm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlDlfs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlSbxh.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXzyy.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlWifi.setBackgroundColor(this.getResources().getColor(
                        R.color.wifi_color));
                mLlTymm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXfcs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));

                mTvCsmm.setCompoundDrawables(mCsmmNot, null, null, null);
                mTvDlfs.setCompoundDrawables(mDlfsNot, null, null, null);
                mTvSbxh.setCompoundDrawables(mSbxhNot, null, null, null);
                mTvXzyy.setCompoundDrawables(mXzyyNot, null, null, null);
                mTvWifi.setCompoundDrawables(mWifiSelect, null, null, null);
                mTvTymm.setCompoundDrawables(mTymmNot, null, null, null);
                mTvXfcs.setCompoundDrawables(mSbxhNot, null, null, null);

                mTvCsmm.setTextColor(this.getResources()
                        .getColor(R.color.suo_color));
                mTvDlfs.setTextColor(this.getResources().getColor(
                        R.color.card_color));
                mTvSbxh.setTextColor(this.getResources().getColor(
                        R.color.setting_color));
                mTvXzyy.setTextColor(this.getResources().getColor(
                        R.color.scan_color));
                mTvWifi.setTextColor(this.getResources().getColor(
                        R.color.white_color));
                mTvTymm.setTextColor(this.getResources().getColor(
                        R.color.visitor_color));
                mTvXfcs.setTextColor(this.getResources().getColor(
                        R.color.setting_color));

                mCsmmPage.setVisibility(View.GONE);
                mDlfsPage.setVisibility(View.GONE);
                mSbxhPage.setVisibility(View.GONE);
                mXzyyPage.setVisibility(View.GONE);
                mTymmPage.setVisibility(View.GONE);
                mWifiPage.setVisibility(View.VISIBLE);
                mSfcsPage.setVisibility(View.GONE);

                findViewById(R.id.ll_wifi_page_button).setVisibility(View.VISIBLE);
                findViewById(R.id.ll_wifi_page_socket).setVisibility(View.GONE);
                break;

            case R.id.ll_tymm:
                mLlCsmm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlDlfs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlSbxh.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXzyy.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlWifi.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlTymm.setBackgroundColor(this.getResources().getColor(
                        R.color.visitor_color));
                mLlXfcs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));

                mTvCsmm.setCompoundDrawables(mCsmmNot, null, null, null);
                mTvDlfs.setCompoundDrawables(mDlfsNot, null, null, null);
                mTvSbxh.setCompoundDrawables(mSbxhNot, null, null, null);
                mTvXzyy.setCompoundDrawables(mXzyyNot, null, null, null);
                mTvWifi.setCompoundDrawables(mWifiNot, null, null, null);
                mTvTymm.setCompoundDrawables(mTymmSelect, null, null, null);
                mTvXfcs.setCompoundDrawables(mSbxhNot, null, null, null);

                mTvCsmm.setTextColor(this.getResources()
                        .getColor(R.color.suo_color));
                mTvDlfs.setTextColor(this.getResources().getColor(
                        R.color.card_color));
                mTvSbxh.setTextColor(this.getResources().getColor(
                        R.color.setting_color));
                mTvXzyy.setTextColor(this.getResources().getColor(
                        R.color.scan_color));
                mTvWifi.setTextColor(this.getResources().getColor(
                        R.color.wifi_color));
                mTvTymm.setTextColor(this.getResources().getColor(
                        R.color.white_color));
                mTvXfcs.setTextColor(this.getResources().getColor(
                        R.color.setting_color));

                mCsmmPage.setVisibility(View.GONE);
                mDlfsPage.setVisibility(View.GONE);
                mSbxhPage.setVisibility(View.GONE);
                mXzyyPage.setVisibility(View.GONE);
                mTymmPage.setVisibility(View.VISIBLE);
                mWifiPage.setVisibility(View.GONE);
                mSfcsPage.setVisibility(View.GONE);

                if (SPUtils.getValueFromSharedFile(this, "tymm", "VISIBLE")
                        .equals("VISIBLE")) {
                    mTymmYes.setCompoundDrawables(null, null, drawable, null);
                } else {
                    mTymmNo.setCompoundDrawables(null, null, drawable, null);
                }
                break;

            case R.id.ll_xfcs:
                mLlCsmm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlDlfs.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlSbxh.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXzyy.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlWifi.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlTymm.setBackgroundColor(this.getResources().getColor(
                        R.color.black_color));
                mLlXfcs.setBackgroundColor(this.getResources().getColor(
                        R.color.setting_color));

                mTvCsmm.setCompoundDrawables(mCsmmNot, null, null, null);
                mTvDlfs.setCompoundDrawables(mDlfsNot, null, null, null);
                mTvSbxh.setCompoundDrawables(mSbxhNot, null, null, null);
                mTvXzyy.setCompoundDrawables(mXzyyNot, null, null, null);
                mTvWifi.setCompoundDrawables(mWifiNot, null, null, null);
                mTvTymm.setCompoundDrawables(mTymmNot, null, null, null);
                mTvXfcs.setCompoundDrawables(mSbxhSelect, null, null, null);

                mTvCsmm.setTextColor(this.getResources()
                        .getColor(R.color.suo_color));
                mTvDlfs.setTextColor(this.getResources().getColor(
                        R.color.card_color));
                mTvSbxh.setTextColor(this.getResources().getColor(
                        R.color.setting_color));
                mTvXzyy.setTextColor(this.getResources().getColor(
                        R.color.scan_color));
                mTvWifi.setTextColor(this.getResources().getColor(
                        R.color.wifi_color));
                mTvTymm.setTextColor(this.getResources().getColor(
                        R.color.visitor_color));
                mTvXfcs.setTextColor(this.getResources().getColor(
                        R.color.white_color));

                mCsmmPage.setVisibility(View.GONE);
                mDlfsPage.setVisibility(View.GONE);
                mSbxhPage.setVisibility(View.GONE);
                mXzyyPage.setVisibility(View.GONE);
                mTymmPage.setVisibility(View.GONE);
                mWifiPage.setVisibility(View.GONE);
                mSfcsPage.setVisibility(View.VISIBLE);
                break;

            case R.id.btn_ok:
                String iniPwd = mStartPwd.getText().toString();
                String newPwd = mNewPwd.getText().toString();
                if ("".equals(iniPwd) || iniPwd == null) {
                    Toast.makeText(this, R.string.no_start_pwd, Toast.LENGTH_SHORT)
                            .show();
                    break;
                } else if ("".equals(newPwd) || newPwd == null) {
                    Toast.makeText(this, R.string.no_new_pwd, Toast.LENGTH_SHORT)
                            .show();
                    break;
                } else {
                    if (iniPwd.equals(SPUtils.getValueFromSharedFile(this,
                            "password", "123456"))) {
                        Toast.makeText(this, R.string.update_success,
                                Toast.LENGTH_SHORT).show();
                        break;
                    } else {
                        SPUtils.setValueSharedFile(this, "password", newPwd);
                        Toast.makeText(this, R.string.update_fail,
                                Toast.LENGTH_SHORT).show();
                        break;
                    }
                }

            case R.id.tv_card:
                if (mSetCardLogin.getVisibility() == View.VISIBLE) {
                    mSetCardLogin.setVisibility(View.INVISIBLE);
                    SPUtils.setValueSharedFile(this, "card", "INVISIBLE");
                } else {
                    mSetCardLogin.setVisibility(View.VISIBLE);
                    SPUtils.setValueSharedFile(this, "card", "VISIBLE");
                }
                break;

            case R.id.tv_scan:
                if (mSetScanLogin.getVisibility() == View.VISIBLE) {
                    mSetScanLogin.setVisibility(View.INVISIBLE);
                    SPUtils.setValueSharedFile(this, "scan", "INVISIBLE");
                } else {
                    mSetScanLogin.setVisibility(View.VISIBLE);
                    SPUtils.setValueSharedFile(this, "scan", "VISIBLE");
                }
                break;

            case R.id.tv_tymm_yes:
                if (SPUtils.getValueFromSharedFile(this, "tymm", "INVISIBLE")
                        .equals("INVISIBLE")) {
                    mTymmYes.setCompoundDrawables(null, null, drawable, null);
                    mTymmNo.setCompoundDrawables(null, null, null, null);
                    SPUtils.setValueSharedFile(this, "tymm", "VISIBLE");
                }
                break;

            case R.id.tv_tymm_no:
                if (SPUtils.getValueFromSharedFile(this, "tymm", "INVISIBLE")
                        .equals("VISIBLE")) {
                    mTymmNo.setCompoundDrawables(null, null, drawable, null);
                    mTymmYes.setCompoundDrawables(null, null, null, null);
                    SPUtils.setValueSharedFile(this, "tymm", "INVISIBLE");
                }
                break;

            case R.id.choose_china:
                if (SPUtils.getValueFromSharedFile(this, "LANGUAGE_KEY", "zh-CN")
                        .equals("en")) {
                    mXzyyChina.setCompoundDrawables(null, null, drawable, null);
                    mXzyyEnglish.setCompoundDrawables(null, null, null, null);
                    MainActivity.showLanguage(this);
                    onCreate(null);
                    SPUtils.setValueSharedFile(this, "LANGUAGE_KEY", "zh-CN");
                }
                break;

            case R.id.choose_english:
                if (SPUtils.getValueFromSharedFile(this, "LANGUAGE_KEY", "zh-CN")
                        .equals("zh-CN")) {
                    mXzyyEnglish.setCompoundDrawables(null, null, drawable, null);
                    mXzyyChina.setCompoundDrawables(null, null, null, null);
                    MainActivity.showLanguage(this);
                    onCreate(null);
                    SPUtils.setValueSharedFile(this, "LANGUAGE_KEY", "en");
                }
                break;

            case R.id.wifi:
                startActivity(new Intent()
                        .setAction("android.net.wifi.PICK_WIFI_NETWORK"));
                break;

            case R.id.socket:
                findViewById(R.id.ll_wifi_page_button).setVisibility(View.GONE);
                findViewById(R.id.ll_wifi_page_socket).setVisibility(View.VISIBLE);
                break;

            case R.id.btn_ok_socket:
                String A = mA.getText().toString();
                String B = mB.getText().toString();
                String C = mC.getText().toString();
                String D = mD.getText().toString();
                if (Integer.parseInt(A) > 255 || Integer.parseInt(B) > 255
                        || Integer.parseInt(C) > 255 || Integer.parseInt(D) > 255) {
                    Toast.makeText(this, "IP地址不合法", Toast.LENGTH_LONG).show();
                    break;
                }
                String IP = A + "." + B + "." + C + "." + D;
                SPUtils.setValueSharedFile(this, "IP", IP);
                Toast.makeText(this, "IP地址设置成功", Toast.LENGTH_LONG).show();
                break;

            case R.id.btn_testConn:
                startMainSendThread(CMDConts.Test_Conn);
                if (Arrays.equals(Temporary, CMDConts.Test_Conn)) {
                    runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                            mTestConn.setText("测试成功");
                        }
                    });
                }
                break;

            case R.id.btn_getLzqLl:
                startMainSendThread(CMDConts.GET_KZQLL);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mTvKzqll.setText((double) Temporary[4] / (double) Temporary[6] + "");
                    }
                });
                break;

            case R.id.btn_xfkzqll:
                String cityStatic = sn_xfkzqll.getSelectedItem().toString();
                if (cityStatic.equals("1")) {
                    postData(CMDConts.XFLLXS01, CMDConts.XFLLXS02);
                } else if (cityStatic.equals("1.25")) {
                    postData(CMDConts.XFLLXS03, CMDConts.XFLLXS04);
                } else if (cityStatic.equals("1.5")) {
                    postData(CMDConts.XFLLXS05, CMDConts.XFLLXS06);
                } else if (cityStatic.equals("1.75")) {
                    postData(CMDConts.XFLLXS07, CMDConts.XFLLXS04);
                } else if (cityStatic.equals("2")) {
                    postData(CMDConts.XFLLXS08, CMDConts.XFLLXS02);
                } else if (cityStatic.equals("2.25")) {
                    postData(CMDConts.XFLLXS09, CMDConts.XFLLXS04);
                } else if (cityStatic.equals("2.5")) {
                    postData(CMDConts.XFLLXS03, CMDConts.XFLLXS06);
                } else if (cityStatic.equals("2.75")) {
                    postData(CMDConts.XFLLXS10, CMDConts.XFLLXS04);
                } else {
                    postData(CMDConts.XFLLXS05, CMDConts.XFLLXS02);
                }
                break;

            case R.id.btn_getQbLi:
                startMainSendThread(CMDConts.GET_QBLL);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mTvQbll.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(7, 10)) / 33 + "");
                    }
                });
                break;

            case R.id.btn_xfqbll:
                if (!TextUtils.isEmpty(mSetQbll.getText())) {
                    int xfqbll = Integer.parseInt(mSetQbll.getText().toString());
                    if (xfqbll <= 10) {
                        startMainSendThread(CMDConts.XFQBLL10);
                        if (Arrays.equals(Temporary, CMDConts.XFQBLL10)) {
                            Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    } else if (xfqbll >= 30) {
                        startMainSendThread(CMDConts.XFQBLL30);
                        if (Arrays.equals(Temporary, CMDConts.XFQBLL30)) {
                            Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    } else {
                        if (xfqbll == 11) {
                            startMainSendThread(CMDConts.XFQBLL11);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL11)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 12) {
                            startMainSendThread(CMDConts.XFQBLL12);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL12)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 13) {
                            startMainSendThread(CMDConts.XFQBLL13);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL13)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 14) {
                            startMainSendThread(CMDConts.XFQBLL14);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL14)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 15) {
                            startMainSendThread(CMDConts.XFQBLL15);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL15)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 16) {
                            startMainSendThread(CMDConts.XFQBLL16);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL16)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 17) {
                            startMainSendThread(CMDConts.XFQBLL17);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL17)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 18) {
                            startMainSendThread(CMDConts.XFQBLL18);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL18)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 19) {
                            startMainSendThread(CMDConts.XFQBLL19);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL19)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 20) {
                            startMainSendThread(CMDConts.XFQBLL20);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL20)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 21) {
                            startMainSendThread(CMDConts.XFQBLL21);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL21)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 22) {
                            startMainSendThread(CMDConts.XFQBLL22);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL22)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 23) {
                            startMainSendThread(CMDConts.XFQBLL23);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL23)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 24) {
                            startMainSendThread(CMDConts.XFQBLL24);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL24)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 25) {
                            startMainSendThread(CMDConts.XFQBLL25);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL25)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 26) {
                            startMainSendThread(CMDConts.XFQBLL26);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL26)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 27) {
                            startMainSendThread(CMDConts.XFQBLL27);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL27)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 28) {
                            startMainSendThread(CMDConts.XFQBLL28);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL28)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfqbll == 29) {
                            startMainSendThread(CMDConts.XFQBLL29);
                            if (Arrays.equals(Temporary, CMDConts.XFQBLL29)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        }
                    }
                } else {
                    Toast.makeText(this, "请填写参数", Toast.LENGTH_SHORT).show();
                }

                break;

            case R.id.btn_getXsz:
                startMainSendThread(CMDConts.GET_XSZ);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mTvXsz.setText(Temporary[4] + "");
                    }
                });
                break;

            case R.id.btn_xfxsz:
                if (!TextUtils.isEmpty(mSetXsz.getText())) {
                    int xfxsz = Integer.parseInt(mSetXsz.getText().toString());
                    if (xfxsz <= 10) {
                        startMainSendThread(CMDConts.SET_XSZ010);
                        if (Arrays.equals(Temporary, CMDConts.SET_XSZ010)) {
                            Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    } else if (xfxsz >= 100) {
                        startMainSendThread(CMDConts.SET_XSZ100);
                        if (Arrays.equals(Temporary, CMDConts.SET_XSZ100)) {
                            Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    } else {
                        if (xfxsz == 11) {
                            startMainSendThread(CMDConts.SET_XSZ011);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ011)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 12) {
                            startMainSendThread(CMDConts.SET_XSZ012);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ012)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 13) {
                            startMainSendThread(CMDConts.SET_XSZ013);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ013)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 14) {
                            startMainSendThread(CMDConts.SET_XSZ014);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ014)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 15) {
                            startMainSendThread(CMDConts.SET_XSZ015);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ015)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 16) {
                            startMainSendThread(CMDConts.SET_XSZ016);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ016)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 17) {
                            startMainSendThread(CMDConts.SET_XSZ017);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ017)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 18) {
                            startMainSendThread(CMDConts.SET_XSZ018);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ018)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 19) {
                            startMainSendThread(CMDConts.SET_XSZ019);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ019)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 20) {
                            startMainSendThread(CMDConts.SET_XSZ020);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ020)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 21) {
                            startMainSendThread(CMDConts.SET_XSZ021);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ021)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 22) {
                            startMainSendThread(CMDConts.SET_XSZ022);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ022)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 23) {
                            startMainSendThread(CMDConts.SET_XSZ023);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ023)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 24) {
                            startMainSendThread(CMDConts.SET_XSZ024);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ024)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 25) {
                            startMainSendThread(CMDConts.SET_XSZ025);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ025)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 26) {
                            startMainSendThread(CMDConts.SET_XSZ026);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ026)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 27) {
                            startMainSendThread(CMDConts.SET_XSZ027);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ027)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 28) {
                            startMainSendThread(CMDConts.SET_XSZ028);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ028)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 29) {
                            startMainSendThread(CMDConts.SET_XSZ029);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ029)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 30) {
                            startMainSendThread(CMDConts.SET_XSZ030);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ030)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 31) {
                            startMainSendThread(CMDConts.SET_XSZ031);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ031)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 32) {
                            startMainSendThread(CMDConts.SET_XSZ032);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ032)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 33) {
                            startMainSendThread(CMDConts.SET_XSZ033);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ033)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 34) {
                            startMainSendThread(CMDConts.SET_XSZ034);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ034)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 35) {
                            startMainSendThread(CMDConts.SET_XSZ035);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ035)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 36) {
                            startMainSendThread(CMDConts.SET_XSZ036);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ036)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 37) {
                            startMainSendThread(CMDConts.SET_XSZ037);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ037)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 38) {
                            startMainSendThread(CMDConts.SET_XSZ038);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ038)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 39) {
                            startMainSendThread(CMDConts.SET_XSZ039);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ039)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 40) {
                            startMainSendThread(CMDConts.SET_XSZ040);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ040)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 41) {
                            startMainSendThread(CMDConts.SET_XSZ041);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ041)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 42) {
                            startMainSendThread(CMDConts.SET_XSZ042);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ042)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 43) {
                            startMainSendThread(CMDConts.SET_XSZ043);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ043)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 44) {
                            startMainSendThread(CMDConts.SET_XSZ044);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ044)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 45) {
                            startMainSendThread(CMDConts.SET_XSZ045);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ045)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 46) {
                            startMainSendThread(CMDConts.SET_XSZ046);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ046)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 47) {
                            startMainSendThread(CMDConts.SET_XSZ047);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ047)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 48) {
                            startMainSendThread(CMDConts.SET_XSZ048);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ048)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 49) {
                            startMainSendThread(CMDConts.SET_XSZ049);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ049)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 50) {
                            startMainSendThread(CMDConts.SET_XSZ050);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ050)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 51) {
                            startMainSendThread(CMDConts.SET_XSZ051);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ051)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 52) {
                            startMainSendThread(CMDConts.SET_XSZ052);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ052)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 53) {
                            startMainSendThread(CMDConts.SET_XSZ053);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ053)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 54) {
                            startMainSendThread(CMDConts.SET_XSZ054);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ054)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 55) {
                            startMainSendThread(CMDConts.SET_XSZ055);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ055)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 56) {
                            startMainSendThread(CMDConts.SET_XSZ056);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ056)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 57) {
                            startMainSendThread(CMDConts.SET_XSZ057);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ057)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 58) {
                            startMainSendThread(CMDConts.SET_XSZ058);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ058)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 59) {
                            startMainSendThread(CMDConts.SET_XSZ059);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ059)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 60) {
                            startMainSendThread(CMDConts.SET_XSZ060);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ060)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 61) {
                            startMainSendThread(CMDConts.SET_XSZ061);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ061)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 62) {
                            startMainSendThread(CMDConts.SET_XSZ062);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ062)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 63) {
                            startMainSendThread(CMDConts.SET_XSZ063);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ063)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 64) {
                            startMainSendThread(CMDConts.SET_XSZ064);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ064)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 65) {
                            startMainSendThread(CMDConts.SET_XSZ065);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ065)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 66) {
                            startMainSendThread(CMDConts.SET_XSZ066);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ066)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 67) {
                            startMainSendThread(CMDConts.SET_XSZ067);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ067)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 68) {
                            startMainSendThread(CMDConts.SET_XSZ068);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ068)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 69) {
                            startMainSendThread(CMDConts.SET_XSZ069);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ069)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 70) {
                            startMainSendThread(CMDConts.SET_XSZ070);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ070)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 71) {
                            startMainSendThread(CMDConts.SET_XSZ071);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ071)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 72) {
                            startMainSendThread(CMDConts.SET_XSZ072);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ072)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 73) {
                            startMainSendThread(CMDConts.SET_XSZ073);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ073)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 74) {
                            startMainSendThread(CMDConts.SET_XSZ074);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ074)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 75) {
                            startMainSendThread(CMDConts.SET_XSZ075);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ075)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 76) {
                            startMainSendThread(CMDConts.SET_XSZ076);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ076)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 77) {
                            startMainSendThread(CMDConts.SET_XSZ077);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ077)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 78) {
                            startMainSendThread(CMDConts.SET_XSZ078);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ078)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 79) {
                            startMainSendThread(CMDConts.SET_XSZ079);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ079)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 80) {
                            startMainSendThread(CMDConts.SET_XSZ080);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ080)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 81) {
                            startMainSendThread(CMDConts.SET_XSZ081);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ081)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 82) {
                            startMainSendThread(CMDConts.SET_XSZ082);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ082)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 83) {
                            startMainSendThread(CMDConts.SET_XSZ083);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ083)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 84) {
                            startMainSendThread(CMDConts.SET_XSZ084);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ084)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 85) {
                            startMainSendThread(CMDConts.SET_XSZ085);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ085)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 86) {
                            startMainSendThread(CMDConts.SET_XSZ086);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ086)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 87) {
                            startMainSendThread(CMDConts.SET_XSZ087);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ087)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 88) {
                            startMainSendThread(CMDConts.SET_XSZ088);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ088)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 89) {
                            startMainSendThread(CMDConts.SET_XSZ089);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ089)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 90) {
                            startMainSendThread(CMDConts.SET_XSZ090);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ090)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 91) {
                            startMainSendThread(CMDConts.SET_XSZ091);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ091)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 92) {
                            startMainSendThread(CMDConts.SET_XSZ092);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ092)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 93) {
                            startMainSendThread(CMDConts.SET_XSZ093);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ093)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 94) {
                            startMainSendThread(CMDConts.SET_XSZ094);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ094)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 95) {
                            startMainSendThread(CMDConts.SET_XSZ095);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ095)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 96) {
                            startMainSendThread(CMDConts.SET_XSZ096);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ096)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 97) {
                            startMainSendThread(CMDConts.SET_XSZ097);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ097)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 98) {
                            startMainSendThread(CMDConts.SET_XSZ098);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ098)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsz == 99) {
                            startMainSendThread(CMDConts.SET_XSZ099);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSZ099)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        }
                    }
                } else {
                    Toast.makeText(this, "请填写参数", Toast.LENGTH_SHORT).show();
                }
                break;

            case R.id.btn_getXszXS:
                startMainSendThread(CMDConts.GET_XSZXS);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mTvXsxs.setText(Temporary[4] + "");
                    }
                });
                break;

            case R.id.btn_xfxsxs:
                if (!TextUtils.isEmpty(mSetXsxs.getText())) {
                    int xfxsxs = Integer.parseInt(mSetXsxs.getText().toString());
                    if (xfxsxs <= 1) {
                        startMainSendThread(CMDConts.SET_XSXS01);
                        if (Arrays.equals(Temporary, CMDConts.SET_XSXS01)) {
                            Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    } else if (xfxsxs >= 55) {
                        startMainSendThread(CMDConts.SET_XSXS55);
                        if (Arrays.equals(Temporary, CMDConts.SET_XSXS55)) {
                            Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                    .show();
                        }
                    } else {
                        if (xfxsxs == 2) {
                            startMainSendThread(CMDConts.SET_XSXS02);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS02)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 3) {
                            startMainSendThread(CMDConts.SET_XSXS03);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS03)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 4) {
                            startMainSendThread(CMDConts.SET_XSXS04);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS04)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 5) {
                            startMainSendThread(CMDConts.SET_XSXS05);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS05)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 6) {
                            startMainSendThread(CMDConts.SET_XSXS06);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS06)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 7) {
                            startMainSendThread(CMDConts.SET_XSXS07);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS07)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 8) {
                            startMainSendThread(CMDConts.SET_XSXS08);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS08)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 9) {
                            startMainSendThread(CMDConts.SET_XSXS09);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS09)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 10) {
                            startMainSendThread(CMDConts.SET_XSXS10);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS10)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 11) {
                            startMainSendThread(CMDConts.SET_XSXS11);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS11)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 12) {
                            startMainSendThread(CMDConts.SET_XSXS12);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS12)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 13) {
                            startMainSendThread(CMDConts.SET_XSXS13);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS13)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 14) {
                            startMainSendThread(CMDConts.SET_XSXS14);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS14)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 15) {
                            startMainSendThread(CMDConts.SET_XSXS15);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS15)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 16) {
                            startMainSendThread(CMDConts.SET_XSXS16);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS16)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 17) {
                            startMainSendThread(CMDConts.SET_XSXS17);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS17)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 18) {
                            startMainSendThread(CMDConts.SET_XSXS18);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS18)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 19) {
                            startMainSendThread(CMDConts.SET_XSXS19);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS19)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 20) {
                            startMainSendThread(CMDConts.SET_XSXS20);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS20)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 21) {
                            startMainSendThread(CMDConts.SET_XSXS21);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS21)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 22) {
                            startMainSendThread(CMDConts.SET_XSXS22);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS22)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 23) {
                            startMainSendThread(CMDConts.SET_XSXS23);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS23)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 24) {
                            startMainSendThread(CMDConts.SET_XSXS24);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS24)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 25) {
                            startMainSendThread(CMDConts.SET_XSXS25);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS25)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 26) {
                            startMainSendThread(CMDConts.SET_XSXS26);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS26)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 27) {
                            startMainSendThread(CMDConts.SET_XSXS27);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS27)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 28) {
                            startMainSendThread(CMDConts.SET_XSXS28);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS28)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 29) {
                            startMainSendThread(CMDConts.SET_XSXS29);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS29)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 30) {
                            startMainSendThread(CMDConts.SET_XSXS30);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS30)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 31) {
                            startMainSendThread(CMDConts.SET_XSXS31);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS31)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 32) {
                            startMainSendThread(CMDConts.SET_XSXS32);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS32)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 33) {
                            startMainSendThread(CMDConts.SET_XSXS33);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS33)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 34) {
                            startMainSendThread(CMDConts.SET_XSXS34);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS34)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 35) {
                            startMainSendThread(CMDConts.SET_XSXS35);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS35)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 36) {
                            startMainSendThread(CMDConts.SET_XSXS36);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS36)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 37) {
                            startMainSendThread(CMDConts.SET_XSXS37);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS37)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 38) {
                            startMainSendThread(CMDConts.SET_XSXS38);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS38)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 39) {
                            startMainSendThread(CMDConts.SET_XSXS39);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS39)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 40) {
                            startMainSendThread(CMDConts.SET_XSXS40);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS40)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 41) {
                            startMainSendThread(CMDConts.SET_XSXS41);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS41)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 42) {
                            startMainSendThread(CMDConts.SET_XSXS42);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS42)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 43) {
                            startMainSendThread(CMDConts.SET_XSXS43);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS43)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 44) {
                            startMainSendThread(CMDConts.SET_XSXS44);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS44)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 45) {
                            startMainSendThread(CMDConts.SET_XSXS45);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS45)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 46) {
                            startMainSendThread(CMDConts.SET_XSXS46);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS46)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 47) {
                            startMainSendThread(CMDConts.SET_XSXS47);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS47)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 48) {
                            startMainSendThread(CMDConts.SET_XSXS48);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS48)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 49) {
                            startMainSendThread(CMDConts.SET_XSXS49);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS49)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 50) {
                            startMainSendThread(CMDConts.SET_XSXS50);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS50)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 51) {
                            startMainSendThread(CMDConts.SET_XSXS51);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS51)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 52) {
                            startMainSendThread(CMDConts.SET_XSXS52);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS52)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 53) {
                            startMainSendThread(CMDConts.SET_XSXS53);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS53)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        } else if (xfxsxs == 54) {
                            startMainSendThread(CMDConts.SET_XSXS54);
                            if (Arrays.equals(Temporary, CMDConts.SET_XSXS54)) {
                                Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                                        .show();
                            }
                        }
                    }
                } else {
                    Toast.makeText(this, "请填写参数", Toast.LENGTH_SHORT).show();
                }
                break;

            case R.id.btn_getstruts:
                startMainSendThread(CMDConts.GET_STRUTS);
                final String struts;
                if (Temporary[4] == 0) {
                    struts = "不矫正";
                } else {
                    struts = "矫正";
                }
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mGetStruts.setText(struts);
                    }
                });
                break;

            case R.id.btn_setyes:
                startMainSendThread(CMDConts.SET_YES);
                if (Arrays.equals(Temporary, CMDConts.SET_YES)) {
                    Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                            .show();
                }
                break;

            case R.id.btn_setno:
                startMainSendThread(CMDConts.SET_NO);
                if (Arrays.equals(Temporary, CMDConts.SET_YES)) {
                    Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT)
                            .show();
                }
                break;

            case R.id.btn_gethsll:
                startMainSendThread(CMDConts.GET_HSLL);
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mSetHsll01.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(7, 10)) / 33 + "");
                        mSetHsll02.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(11, 14)) / 33 + "");
                        mSetHsll03.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(15, 18)) / 33 + "");
                        mSetHsll04.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(19, 22)) / 33 + "");
                        mSetHsll05.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(23, 26)) / 33 + "");
                        mSetHsll06.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(27, 30)) / 33 + "");
                        mSetHsll07.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(31, 34)) / 33 + "");
                        mSetHsll08.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(35, 38)) / 33 + "");
                        mSetHsll09.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(39, 42)) / 33 + "");
                        mSetHsll10.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(43, 46)) / 33 + "");
                        mSetHsll11.setText(DataCovertUtil.HexToInt(DataCovertUtil
                                .ByteArrToHex(Temporary).substring(47, 50)) / 33 + "");
                    }
                });
                break;

            case R.id.btn_sethsll:
                if (!TextUtils.isEmpty(mSetHsll01.getText())) {
                    int xfhsll01 = Integer.parseInt(mSetHsll01.getText().toString());
                    if (xfhsll01 <= 10) {
                        list.add(CMDConts.SET_HSLL0110);
                    } else if (xfhsll01 >= 32) {
                        list.add(CMDConts.SET_HSLL0132);
                    } else {
                        switch (xfhsll01) {
                            case 11:
                                list.add(CMDConts.SET_HSLL0111);
                                break;
                            case 12:
                                list.add(CMDConts.SET_HSLL0112);
                                break;
                            case 13:
                                list.add(CMDConts.SET_HSLL0113);
                                break;
                            case 14:
                                list.add(CMDConts.SET_HSLL0114);
                                break;
                            case 15:
                                list.add(CMDConts.SET_HSLL0115);
                                break;
                            case 16:
                                list.add(CMDConts.SET_HSLL0116);
                                break;
                            case 17:
                                list.add(CMDConts.SET_HSLL0117);
                                break;
                            case 18:
                                list.add(CMDConts.SET_HSLL0118);
                                break;
                            case 19:
                                list.add(CMDConts.SET_HSLL0119);
                                break;
                            case 20:
                                list.add(CMDConts.SET_HSLL0120);
                                break;
                            case 21:
                                list.add(CMDConts.SET_HSLL0121);
                                break;
                            case 22:
                                list.add(CMDConts.SET_HSLL0122);
                                break;
                            case 23:
                                list.add(CMDConts.SET_HSLL0123);
                                break;
                            case 24:
                                list.add(CMDConts.SET_HSLL0124);
                                break;
                            case 25:
                                list.add(CMDConts.SET_HSLL0125);
                                break;
                            case 26:
                                list.add(CMDConts.SET_HSLL0126);
                                break;
                            case 27:
                                list.add(CMDConts.SET_HSLL0127);
                                break;
                            case 28:
                                list.add(CMDConts.SET_HSLL0128);
                                break;
                            case 29:
                                list.add(CMDConts.SET_HSLL0129);
                                break;
                            case 30:
                                list.add(CMDConts.SET_HSLL0130);
                                break;
                            case 31:
                                list.add(CMDConts.SET_HSLL0131);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll02.getText())) {
                    int xfhsll02 = Integer.parseInt(mSetHsll02.getText().toString());
                    if (xfhsll02 <= 13) {
                        list.add(CMDConts.SET_HSLL0213);
                    } else if (xfhsll02 >= 35) {
                        list.add(CMDConts.SET_HSLL0235);
                    } else {
                        switch (xfhsll02) {
                            case 14:
                                list.add(CMDConts.SET_HSLL0214);
                                break;
                            case 15:
                                list.add(CMDConts.SET_HSLL0215);
                                break;
                            case 16:
                                list.add(CMDConts.SET_HSLL0216);
                                break;
                            case 17:
                                list.add(CMDConts.SET_HSLL0217);
                                break;
                            case 18:
                                list.add(CMDConts.SET_HSLL0218);
                                break;
                            case 19:
                                list.add(CMDConts.SET_HSLL0219);
                                break;
                            case 20:
                                list.add(CMDConts.SET_HSLL0220);
                                break;
                            case 21:
                                list.add(CMDConts.SET_HSLL0221);
                                break;
                            case 22:
                                list.add(CMDConts.SET_HSLL0222);
                                break;
                            case 23:
                                list.add(CMDConts.SET_HSLL0223);
                                break;
                            case 24:
                                list.add(CMDConts.SET_HSLL0224);
                                break;
                            case 25:
                                list.add(CMDConts.SET_HSLL0225);
                                break;
                            case 26:
                                list.add(CMDConts.SET_HSLL0226);
                                break;
                            case 27:
                                list.add(CMDConts.SET_HSLL0227);
                                break;
                            case 28:
                                list.add(CMDConts.SET_HSLL0228);
                                break;
                            case 29:
                                list.add(CMDConts.SET_HSLL0229);
                                break;
                            case 30:
                                list.add(CMDConts.SET_HSLL0230);
                                break;
                            case 31:
                                list.add(CMDConts.SET_HSLL0231);
                                break;
                            case 32:
                                list.add(CMDConts.SET_HSLL0232);
                                break;
                            case 33:
                                list.add(CMDConts.SET_HSLL0233);
                                break;
                            case 34:
                                list.add(CMDConts.SET_HSLL0234);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll03.getText())) {
                    int xfhsll03 = Integer.parseInt(mSetHsll03.getText().toString());
                    if (xfhsll03 <= 16) {
                        list.add(CMDConts.SET_HSLL0316);
                    } else if (xfhsll03 >= 38) {
                        list.add(CMDConts.SET_HSLL0338);
                    } else {
                        switch (xfhsll03) {
                            case 17:
                                list.add(CMDConts.SET_HSLL0317);
                                break;
                            case 18:
                                list.add(CMDConts.SET_HSLL0318);
                                break;
                            case 19:
                                list.add(CMDConts.SET_HSLL0319);
                                break;
                            case 20:
                                list.add(CMDConts.SET_HSLL0320);
                                break;
                            case 21:
                                list.add(CMDConts.SET_HSLL0321);
                                break;
                            case 22:
                                list.add(CMDConts.SET_HSLL0322);
                                break;
                            case 23:
                                list.add(CMDConts.SET_HSLL0323);
                                break;
                            case 24:
                                list.add(CMDConts.SET_HSLL0324);
                                break;
                            case 25:
                                list.add(CMDConts.SET_HSLL0325);
                                break;
                            case 26:
                                list.add(CMDConts.SET_HSLL0326);
                                break;
                            case 27:
                                list.add(CMDConts.SET_HSLL0327);
                                break;
                            case 28:
                                list.add(CMDConts.SET_HSLL0328);
                                break;
                            case 29:
                                list.add(CMDConts.SET_HSLL0329);
                                break;
                            case 30:
                                list.add(CMDConts.SET_HSLL0330);
                                break;
                            case 31:
                                list.add(CMDConts.SET_HSLL0331);
                                break;
                            case 32:
                                list.add(CMDConts.SET_HSLL0332);
                                break;
                            case 33:
                                list.add(CMDConts.SET_HSLL0333);
                                break;
                            case 34:
                                list.add(CMDConts.SET_HSLL0334);
                                break;
                            case 35:
                                list.add(CMDConts.SET_HSLL0335);
                                break;
                            case 36:
                                list.add(CMDConts.SET_HSLL0336);
                                break;
                            case 37:
                                list.add(CMDConts.SET_HSLL0337);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll04.getText())) {
                    int xfhsll04 = Integer.parseInt(mSetHsll04.getText().toString());
                    if (xfhsll04 <= 19) {
                        list.add(CMDConts.SET_HSLL0419);
                    } else if (xfhsll04 >= 41) {
                        list.add(CMDConts.SET_HSLL0441);
                    } else {
                        switch (xfhsll04) {
                            case 20:
                                list.add(CMDConts.SET_HSLL0420);
                                break;
                            case 21:
                                list.add(CMDConts.SET_HSLL0421);
                                break;
                            case 22:
                                list.add(CMDConts.SET_HSLL0422);
                                break;
                            case 23:
                                list.add(CMDConts.SET_HSLL0423);
                                break;
                            case 24:
                                list.add(CMDConts.SET_HSLL0424);
                                break;
                            case 25:
                                list.add(CMDConts.SET_HSLL0425);
                                break;
                            case 26:
                                list.add(CMDConts.SET_HSLL0426);
                                break;
                            case 27:
                                list.add(CMDConts.SET_HSLL0427);
                                break;
                            case 28:
                                list.add(CMDConts.SET_HSLL0428);
                                break;
                            case 29:
                                list.add(CMDConts.SET_HSLL0429);
                                break;
                            case 30:
                                list.add(CMDConts.SET_HSLL0430);
                                break;
                            case 31:
                                list.add(CMDConts.SET_HSLL0431);
                                break;
                            case 32:
                                list.add(CMDConts.SET_HSLL0432);
                                break;
                            case 33:
                                list.add(CMDConts.SET_HSLL0433);
                                break;
                            case 34:
                                list.add(CMDConts.SET_HSLL0434);
                                break;
                            case 35:
                                list.add(CMDConts.SET_HSLL0435);
                                break;
                            case 36:
                                list.add(CMDConts.SET_HSLL0436);
                                break;
                            case 37:
                                list.add(CMDConts.SET_HSLL0437);
                                break;
                            case 38:
                                list.add(CMDConts.SET_HSLL0438);
                                break;
                            case 39:
                                list.add(CMDConts.SET_HSLL0439);
                                break;
                            case 40:
                                list.add(CMDConts.SET_HSLL0440);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll05.getText())) {
                    int xfhsll05 = Integer.parseInt(mSetHsll05.getText().toString());
                    if (xfhsll05 <= 22) {
                        list.add(CMDConts.SET_HSLL0522);
                    } else if (xfhsll05 >= 44) {
                        list.add(CMDConts.SET_HSLL0544);
                    } else {
                        switch (xfhsll05) {
                            case 23:
                                list.add(CMDConts.SET_HSLL0523);
                                break;
                            case 24:
                                list.add(CMDConts.SET_HSLL0524);
                                break;
                            case 25:
                                list.add(CMDConts.SET_HSLL0525);
                                break;
                            case 26:
                                list.add(CMDConts.SET_HSLL0526);
                                break;
                            case 27:
                                list.add(CMDConts.SET_HSLL0527);
                                break;
                            case 28:
                                list.add(CMDConts.SET_HSLL0528);
                                break;
                            case 29:
                                list.add(CMDConts.SET_HSLL0529);
                                break;
                            case 30:
                                list.add(CMDConts.SET_HSLL0530);
                                break;
                            case 31:
                                list.add(CMDConts.SET_HSLL0531);
                                break;
                            case 32:
                                list.add(CMDConts.SET_HSLL0532);
                                break;
                            case 33:
                                list.add(CMDConts.SET_HSLL0533);
                                break;
                            case 34:
                                list.add(CMDConts.SET_HSLL0534);
                                break;
                            case 35:
                                list.add(CMDConts.SET_HSLL0535);
                                break;
                            case 36:
                                list.add(CMDConts.SET_HSLL0536);
                                break;
                            case 37:
                                list.add(CMDConts.SET_HSLL0537);
                                break;
                            case 38:
                                list.add(CMDConts.SET_HSLL0538);
                                break;
                            case 39:
                                list.add(CMDConts.SET_HSLL0539);
                                break;
                            case 40:
                                list.add(CMDConts.SET_HSLL0540);
                                break;
                            case 41:
                                list.add(CMDConts.SET_HSLL0541);
                                break;
                            case 42:
                                list.add(CMDConts.SET_HSLL0542);
                                break;
                            case 43:
                                list.add(CMDConts.SET_HSLL0543);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll06.getText())) {
                    int xfhsll06 = Integer.parseInt(mSetHsll06.getText().toString());
                    if (xfhsll06 <= 25) {
                        list.add(CMDConts.SET_HSLL0625);
                    } else if (xfhsll06 >= 47) {
                        list.add(CMDConts.SET_HSLL0647);
                    } else {
                        switch (xfhsll06) {
                            case 26:
                                list.add(CMDConts.SET_HSLL0626);
                                break;
                            case 27:
                                list.add(CMDConts.SET_HSLL0627);
                                break;
                            case 28:
                                list.add(CMDConts.SET_HSLL0628);
                                break;
                            case 29:
                                list.add(CMDConts.SET_HSLL0629);
                                break;
                            case 30:
                                list.add(CMDConts.SET_HSLL0630);
                                break;
                            case 31:
                                list.add(CMDConts.SET_HSLL0631);
                                break;
                            case 32:
                                list.add(CMDConts.SET_HSLL0632);
                                break;
                            case 33:
                                list.add(CMDConts.SET_HSLL0633);
                                break;
                            case 34:
                                list.add(CMDConts.SET_HSLL0634);
                                break;
                            case 35:
                                list.add(CMDConts.SET_HSLL0635);
                                break;
                            case 36:
                                list.add(CMDConts.SET_HSLL0636);
                                break;
                            case 37:
                                list.add(CMDConts.SET_HSLL0637);
                                break;
                            case 38:
                                list.add(CMDConts.SET_HSLL0638);
                                break;
                            case 39:
                                list.add(CMDConts.SET_HSLL0639);
                                break;
                            case 40:
                                list.add(CMDConts.SET_HSLL0640);
                                break;
                            case 41:
                                list.add(CMDConts.SET_HSLL0641);
                                break;
                            case 42:
                                list.add(CMDConts.SET_HSLL0642);
                                break;
                            case 43:
                                list.add(CMDConts.SET_HSLL0643);
                                break;
                            case 44:
                                list.add(CMDConts.SET_HSLL0644);
                                break;
                            case 45:
                                list.add(CMDConts.SET_HSLL0645);
                                break;
                            case 46:
                                list.add(CMDConts.SET_HSLL0646);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll07.getText())) {
                    int xfhsll07 = Integer.parseInt(mSetHsll07.getText().toString());
                    if (xfhsll07 <= 28) {
                        list.add(CMDConts.SET_HSLL0728);
                    } else if (xfhsll07 >= 50) {
                        list.add(CMDConts.SET_HSLL0750);
                    } else {
                        switch (xfhsll07) {
                            case 29:
                                list.add(CMDConts.SET_HSLL0729);
                                break;
                            case 30:
                                list.add(CMDConts.SET_HSLL0730);
                                break;
                            case 31:
                                list.add(CMDConts.SET_HSLL0731);
                                break;
                            case 32:
                                list.add(CMDConts.SET_HSLL0732);
                                break;
                            case 33:
                                list.add(CMDConts.SET_HSLL0733);
                                break;
                            case 34:
                                list.add(CMDConts.SET_HSLL0734);
                                break;
                            case 35:
                                list.add(CMDConts.SET_HSLL0735);
                                break;
                            case 36:
                                list.add(CMDConts.SET_HSLL0736);
                                break;
                            case 37:
                                list.add(CMDConts.SET_HSLL0737);
                                break;
                            case 38:
                                list.add(CMDConts.SET_HSLL0738);
                                break;
                            case 39:
                                list.add(CMDConts.SET_HSLL0739);
                                break;
                            case 40:
                                list.add(CMDConts.SET_HSLL0740);
                                break;
                            case 41:
                                list.add(CMDConts.SET_HSLL0741);
                                break;
                            case 42:
                                list.add(CMDConts.SET_HSLL0742);
                                break;
                            case 43:
                                list.add(CMDConts.SET_HSLL0743);
                                break;
                            case 44:
                                list.add(CMDConts.SET_HSLL0744);
                                break;
                            case 45:
                                list.add(CMDConts.SET_HSLL0745);
                                break;
                            case 46:
                                list.add(CMDConts.SET_HSLL0746);
                                break;
                            case 47:
                                list.add(CMDConts.SET_HSLL0747);
                                break;
                            case 48:
                                list.add(CMDConts.SET_HSLL0748);
                                break;
                            case 49:
                                list.add(CMDConts.SET_HSLL0749);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll08.getText())) {
                    int xfhsll08 = Integer.parseInt(mSetHsll08.getText().toString());
                    if (xfhsll08 <= 31) {
                        list.add(CMDConts.SET_HSLL0831);
                    } else if (xfhsll08 >= 53) {
                        list.add(CMDConts.SET_HSLL0853);
                    } else {
                        switch (xfhsll08) {
                            case 32:
                                list.add(CMDConts.SET_HSLL0832);
                                break;
                            case 33:
                                list.add(CMDConts.SET_HSLL0833);
                                break;
                            case 34:
                                list.add(CMDConts.SET_HSLL0834);
                                break;
                            case 35:
                                list.add(CMDConts.SET_HSLL0835);
                                break;
                            case 36:
                                list.add(CMDConts.SET_HSLL0836);
                                break;
                            case 37:
                                list.add(CMDConts.SET_HSLL0837);
                                break;
                            case 38:
                                list.add(CMDConts.SET_HSLL0838);
                                break;
                            case 39:
                                list.add(CMDConts.SET_HSLL0839);
                                break;
                            case 40:
                                list.add(CMDConts.SET_HSLL0840);
                                break;
                            case 41:
                                list.add(CMDConts.SET_HSLL0841);
                                break;
                            case 42:
                                list.add(CMDConts.SET_HSLL0842);
                                break;
                            case 43:
                                list.add(CMDConts.SET_HSLL0843);
                                break;
                            case 44:
                                list.add(CMDConts.SET_HSLL0844);
                                break;
                            case 45:
                                list.add(CMDConts.SET_HSLL0845);
                                break;
                            case 46:
                                list.add(CMDConts.SET_HSLL0846);
                                break;
                            case 47:
                                list.add(CMDConts.SET_HSLL0847);
                                break;
                            case 48:
                                list.add(CMDConts.SET_HSLL0848);
                                break;
                            case 49:
                                list.add(CMDConts.SET_HSLL0849);
                                startMainSendThread(CMDConts.SET_HSLL0935);
                                break;
                            case 50:
                                list.add(CMDConts.SET_HSLL0850);
                                startMainSendThread(CMDConts.SET_HSLL0935);
                                break;
                            case 51:
                                list.add(CMDConts.SET_HSLL0851);
                                startMainSendThread(CMDConts.SET_HSLL0935);
                                break;
                            case 52:
                                list.add(CMDConts.SET_HSLL0852);
                                startMainSendThread(CMDConts.SET_HSLL0935);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll09.getText())) {
                    int xfhsll09 = Integer.parseInt(mSetHsll09.getText().toString());
                    if (xfhsll09 <= 34) {
                        list.add(CMDConts.SET_HSLL0934);
                    } else if (xfhsll09 >= 56) {
                        list.add(CMDConts.SET_HSLL0956);
                    } else {
                        switch (xfhsll09) {
                            case 35:
                                list.add(CMDConts.SET_HSLL0935);
//						startMainSendThread(CMDConts.SET_HSLL0935);
                                break;
                            case 36:
                                list.add(CMDConts.SET_HSLL0936);
//						startMainSendThread(CMDConts.SET_HSLL0936);
                                break;
                            case 37:
                                list.add(CMDConts.SET_HSLL0937);
//						startMainSendThread(CMDConts.SET_HSLL0937);
                                break;
                            case 38:
                                list.add(CMDConts.SET_HSLL0938);
//						startMainSendThread(CMDConts.SET_HSLL0938);
                                break;
                            case 39:
                                list.add(CMDConts.SET_HSLL0939);
//						startMainSendThread(CMDConts.SET_HSLL0939);
                                break;
                            case 40:
                                list.add(CMDConts.SET_HSLL0940);
//						startMainSendThread(CMDConts.SET_HSLL0940);
                                break;
                            case 41:
                                list.add(CMDConts.SET_HSLL0941);
//						startMainSendThread(CMDConts.SET_HSLL0941);
                                break;
                            case 42:
                                list.add(CMDConts.SET_HSLL0942);
//						startMainSendThread(CMDConts.SET_HSLL0942);
                                break;
                            case 43:
                                list.add(CMDConts.SET_HSLL0943);
//						startMainSendThread(CMDConts.SET_HSLL0943);
                                break;
                            case 44:
                                list.add(CMDConts.SET_HSLL0944);
//						startMainSendThread(CMDConts.SET_HSLL0944);
                                break;
                            case 45:
                                list.add(CMDConts.SET_HSLL0945);
//						startMainSendThread(CMDConts.SET_HSLL0945);
                                break;
                            case 46:
                                list.add(CMDConts.SET_HSLL0946);
//						startMainSendThread(CMDConts.SET_HSLL0946);
                                break;
                            case 47:
                                list.add(CMDConts.SET_HSLL0947);
//						startMainSendThread(CMDConts.SET_HSLL0947);
                                break;
                            case 48:
                                list.add(CMDConts.SET_HSLL0948);
//						startMainSendThread(CMDConts.SET_HSLL0948);
                                break;
                            case 49:
                                list.add(CMDConts.SET_HSLL0949);
//						startMainSendThread(CMDConts.SET_HSLL0949);
                                break;
                            case 50:
                                list.add(CMDConts.SET_HSLL0950);
//						startMainSendThread(CMDConts.SET_HSLL0950);
                                break;
                            case 51:
                                list.add(CMDConts.SET_HSLL0951);
//						startMainSendThread(CMDConts.SET_HSLL0951);
                                break;
                            case 52:
                                list.add(CMDConts.SET_HSLL0952);
//						startMainSendThread(CMDConts.SET_HSLL0952);
                                break;
                            case 53:
                                list.add(CMDConts.SET_HSLL0953);
//						startMainSendThread(CMDConts.SET_HSLL0953);
                                break;
                            case 54:
                                list.add(CMDConts.SET_HSLL0954);
//						startMainSendThread(CMDConts.SET_HSLL0954);
                                break;
                            case 55:
                                list.add(CMDConts.SET_HSLL0955);
//						startMainSendThread(CMDConts.SET_HSLL0955);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll10.getText())) {
                    int xfhsll10 = Integer.parseInt(mSetHsll10.getText().toString());
                    if (xfhsll10 <= 37) {
                        list.add(CMDConts.SET_HSLL1037);
//					startMainSendThread(CMDConts.SET_HSLL1037);
                    } else if (xfhsll10 >= 59) {
                        list.add(CMDConts.SET_HSLL1059);
//					startMainSendThread(CMDConts.SET_HSLL1059);
                    } else {
                        switch (xfhsll10) {
                            case 38:
                                list.add(CMDConts.SET_HSLL1038);
//						startMainSendThread(CMDConts.SET_HSLL1038);
                                break;
                            case 39:
                                list.add(CMDConts.SET_HSLL1039);
//						startMainSendThread(CMDConts.SET_HSLL1039);
                                break;
                            case 40:
                                list.add(CMDConts.SET_HSLL1040);
//						startMainSendThread(CMDConts.SET_HSLL1040);
                                break;
                            case 41:
                                list.add(CMDConts.SET_HSLL1041);
//						startMainSendThread(CMDConts.SET_HSLL1041);
                                break;
                            case 42:
                                list.add(CMDConts.SET_HSLL1042);
//						startMainSendThread(CMDConts.SET_HSLL1042);
                                break;
                            case 43:
                                list.add(CMDConts.SET_HSLL1043);
//						startMainSendThread(CMDConts.SET_HSLL1043);
                                break;
                            case 44:
                                list.add(CMDConts.SET_HSLL1044);
//						startMainSendThread(CMDConts.SET_HSLL1044);
                                break;
                            case 45:
                                list.add(CMDConts.SET_HSLL1045);
//						startMainSendThread(CMDConts.SET_HSLL1045);
                                break;
                            case 46:
                                list.add(CMDConts.SET_HSLL1046);
//						startMainSendThread(CMDConts.SET_HSLL1046);
                                break;
                            case 47:
                                list.add(CMDConts.SET_HSLL1047);
//						startMainSendThread(CMDConts.SET_HSLL1047);
                                break;
                            case 48:
                                list.add(CMDConts.SET_HSLL1048);
//						startMainSendThread(CMDConts.SET_HSLL1048);
                                break;
                            case 49:
                                list.add(CMDConts.SET_HSLL1049);
//						startMainSendThread(CMDConts.SET_HSLL1049);
                                break;
                            case 50:
                                list.add(CMDConts.SET_HSLL1050);
//						startMainSendThread(CMDConts.SET_HSLL1050);
                                break;
                            case 51:
                                list.add(CMDConts.SET_HSLL1051);
//						startMainSendThread(CMDConts.SET_HSLL1051);
                                break;
                            case 52:
                                list.add(CMDConts.SET_HSLL1052);
//						startMainSendThread(CMDConts.SET_HSLL1052);
                                break;
                            case 53:
                                list.add(CMDConts.SET_HSLL1053);
//						startMainSendThread(CMDConts.SET_HSLL1053);
                                break;
                            case 54:
                                list.add(CMDConts.SET_HSLL1054);
//						startMainSendThread(CMDConts.SET_HSLL1054);
                                break;
                            case 55:
                                list.add(CMDConts.SET_HSLL1055);
//						startMainSendThread(CMDConts.SET_HSLL1055);
                                break;
                            case 56:
                                list.add(CMDConts.SET_HSLL1056);
//						startMainSendThread(CMDConts.SET_HSLL1056);
                                break;
                            case 57:
                                list.add(CMDConts.SET_HSLL1057);
//						startMainSendThread(CMDConts.SET_HSLL1057);
                                break;
                            case 58:
                                list.add(CMDConts.SET_HSLL1058);
//						startMainSendThread(CMDConts.SET_HSLL1058);
                                break;
                        }
                    }
                }
                if (!TextUtils.isEmpty(mSetHsll11.getText())) {
                    int xfhsll11 = Integer.parseInt(mSetHsll11.getText().toString());
                    if (xfhsll11 <= 40) {
                        list.add(CMDConts.SET_HSLL1140);
//					startMainSendThread(CMDConts.SET_HSLL1140);
                    } else if (xfhsll11 >= 62) {
                        list.add(CMDConts.SET_HSLL1162);
//					startMainSendThread(CMDConts.SET_HSLL1162);
                    } else {
                        switch (xfhsll11) {
                            case 41:
//						list.add(CMDConts.SET_HSLL1141);
                                startMainSendThread(CMDConts.SET_HSLL1141);
                                break;
                            case 42:
                                list.add(CMDConts.SET_HSLL1142);
//						startMainSendThread(CMDConts.SET_HSLL1142);
                                break;
                            case 43:
                                list.add(CMDConts.SET_HSLL1143);
//						startMainSendThread(CMDConts.SET_HSLL1143);
                                break;
                            case 44:
                                list.add(CMDConts.SET_HSLL1144);
//						startMainSendThread(CMDConts.SET_HSLL1144);
                                break;
                            case 45:
                                list.add(CMDConts.SET_HSLL1145);
//						startMainSendThread(CMDConts.SET_HSLL1145);
                                break;
                            case 46:
                                list.add(CMDConts.SET_HSLL1146);
//						startMainSendThread(CMDConts.SET_HSLL1146);
                                break;
                            case 47:
                                list.add(CMDConts.SET_HSLL1147);
//						startMainSendThread(CMDConts.SET_HSLL1147);
                                break;
                            case 48:
                                list.add(CMDConts.SET_HSLL1148);
//						startMainSendThread(CMDConts.SET_HSLL1148);
                                break;
                            case 49:
                                list.add(CMDConts.SET_HSLL1149);
//						startMainSendThread(CMDConts.SET_HSLL1149);
                                break;
                            case 50:
                                list.add(CMDConts.SET_HSLL1150);
//						startMainSendThread(CMDConts.SET_HSLL1150);
                                break;
                            case 51:
                                list.add(CMDConts.SET_HSLL1151);
//						startMainSendThread(CMDConts.SET_HSLL1151);
                                break;
                            case 52:
                                list.add(CMDConts.SET_HSLL1152);
//						startMainSendThread(CMDConts.SET_HSLL1152);
                                break;
                            case 53:
                                list.add(CMDConts.SET_HSLL1153);
//						startMainSendThread(CMDConts.SET_HSLL1153);
                                break;
                            case 54:
                                list.add(CMDConts.SET_HSLL1154);
//						startMainSendThread(CMDConts.SET_HSLL1154);
                                break;
                            case 55:
                                list.add(CMDConts.SET_HSLL1155);
//						startMainSendThread(CMDConts.SET_HSLL1155);
                                break;
                            case 56:
                                list.add(CMDConts.SET_HSLL1156);
//						startMainSendThread(CMDConts.SET_HSLL1156);
                                break;
                            case 57:
                                list.add(CMDConts.SET_HSLL1157);
//						startMainSendThread(CMDConts.SET_HSLL1157);
                                break;
                            case 58:
                                list.add(CMDConts.SET_HSLL1158);
//						startMainSendThread(CMDConts.SET_HSLL1158);
                                break;
                            case 59:
                                list.add(CMDConts.SET_HSLL1159);
//						startMainSendThread(CMDConts.SET_HSLL1159);
                                break;
                            case 60:
                                list.add(CMDConts.SET_HSLL1160);
//						startMainSendThread(CMDConts.SET_HSLL1160);
                                break;
                            case 61:
                                list.add(CMDConts.SET_HSLL1161);
//						startMainSendThread(CMDConts.SET_HSLL1161);
                                break;
                        }
                    }
                }
                startSendThread(list);
                break;
            default:
                break;
        }
    }

    private void startMainSendThread(byte[] b) {
        List<byte[]> cmdList = new ArrayList<byte[]>();
        cmdList.add(b);
        mSendThread = new SendThread(cmdList, false);
        mSendThread.start();
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        closeStartThread();
    }

    private void startSendThread(ArrayList<byte[]> l) {
        mSendThread = new SendThread(l, false);
        mSendThread.start();
        closeStartThread();
    }

    private void postData(byte[] a, byte[] b) {
        startMainSendThread(a);
        try {
            Thread.sleep(200);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        startMainSendThread(b);
        Toast.makeText(this, "参数下发完成", Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onDataReceived(ComReceiveDataBean ComRecData) {
        if (ComRecData.getCRC(ComRecData.bRec).equals("0")) {
            Temporary = new byte[ComRecData.bRec.length];
            for (int i = 0; i < ComRecData.bRec.length; i++) {
                Temporary[i] = ComRecData.bRec[i];
            }
        }
    }
}
